define(function(require, exports, module){
	var myfocusTemp = require("text!../template/myfocus.html");

	module.exports = Nuui.View.extend({

		template:myfocusTemp,

		onRender:function(){
			var view = this;
			view.$('.smart-title a').on('tap', function(){
				var self = $(this);
				self.addClass('at-active').siblings().removeClass('at-active');
				queryMyFocusList();
				return false;
			});
			var queryMyFocusList=function(){
				App.request(App.server.getServePath(App.path.myFocusAction), {
				//data:"",
				success:function(data){

					if(data.ec){
						alert(data.em);
						
					}else{

						view.$(".smart-content").empty();
						var targetItem=view.$('.smart-title a.at-active h2').attr('data-code');
//						var personLists = data.smartGroupList.IndustryExperts.list;
						var personLists = data.smartGroupList[targetItem].list;
						var parentCode=data.smartGroupList[targetItem].menuCode;
						for(var item=0;item< personLists.length;item++){
							var html='';
							html+='';
							html+='<li data-id="'+personLists[item].id+'"  data-code="'+parentCode+'" class="company-list">';
							html+='	<div class="part-left">';
							html+='		<img src="../../../images/img/'+personLists[item].avatar+'" alt="" />';
							html+='	</div>';
							html+='	<div class="part-right">';
							html+='		<h3 class="title">'+personLists[item].name+'</h3>';
							html+='		<div class="bottom">';
							html+='			<div class="date">'+personLists[item].date+'</div>';
							html+='			<div class="operation">';
							html+='			<img src="../../../images/img/cancelFocus.png" alt="" />';
											
							html+='			</div>';
	
							html+='		</div>';
							html+='	</div>';
							html+='</li>';
							view.$("#myFocusList").append(html);
						}
						
						// $(".avatar img").attr("src",userInfo.photo);
					}
				}
				});
			}
			
			queryMyFocusList();
			
			
			var photo = App.storage.get("photo");
			if(photo){
				this.$(".avatar img").attr("src", "data:image/png;base64," + photo);
			}
			
			
			
		},

		onShow:function(){
          var view=this;
          view.$('.smart-content').on('tap','li',function(){
				var targetCode=$(this).attr('data-code');
				var targetId=$(this).attr('data-id');
				if(targetCode=="IndustryExperts"||targetCode=='GovernmentAdviser'){
					App.storage.set('smartGroupMenuCode',targetCode);
					App.storage.set('smartGroupListId',targetId);
					App.navigate("example/index/thinktankdetails", true);
				}else{

					sessionStorage.setItem("key",targetId);
					App.navigate("example/index/productService", true);
				}
				
						return false;
			})
			view.$('.smart-content').on('tap','li .operation',function(e){
				var e=e||event;
				e.stopPropagation();
				e.cancelBubble=true;
				var li=$(this).closest('li');
				li.addClass('active').delay(300).queue(function(){
					$(this).remove();
					$(this).dequeue();
				});
			})
		}
	});
});
